package user;  
import java.sql.*;  
public class UserRegister {
	private UserBean userBean;  
    private Connection con;  
    public UserRegister()  
    {  
      String url="jdbc:mysql://localhost/"+"tosyokannri"+"?user="+"root"+"&password="+"x5";  
    try  
    {  
      Class.forName("com.mysql.jdbc.Driver").newInstance();  
      con = DriverManager.getConnection(url);  
     }
    catch(Exception e)
    {  
      e.printStackTrace();  
    }  
    }  
    public void setUserBean(UserBean userBean)  
    {  
      this.userBean=userBean;  
    }  
    public void regist() throws Exception  
    {  
      String reg="insert into userinfo(userid,password)  values(?,?)";  
    try  
    {  
      PreparedStatement pstmt=con.prepareStatement(reg);  
      pstmt.setString(1,userBean.getUserId());  
      pstmt.setString(2,userBean.getPassword());  
      pstmt.executeUpdate();  
    }  
    catch(Exception e)  
    {
      e.printStackTrace();  
      throw e;  
    }  
    }  

}
